package com.company.project.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 第三方接口配置
 */
@Component
@ConfigurationProperties(prefix = "third-party")
public class ThirdPartyConfig {
    
    /**
     * 文件上传接口地址
     */
    private String uploadUrl = "http://localhost:8004/api/upload";
    
    /**
     * 文件下载接口地址
     */
    private String downloadUrl = "http://localhost:8004/api/download";
    
    /**
     * 第三方服务基础地址
     */
    private String baseUrl = "http://localhost:8004";
    
    public String getUploadUrl() {
        return uploadUrl;
    }
    
    public void setUploadUrl(String uploadUrl) {
        this.uploadUrl = uploadUrl;
    }
    
    public String getDownloadUrl() {
        return downloadUrl;
    }
    
    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }
    
    public String getBaseUrl() {
        return baseUrl;
    }
    
    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
    
    /**
     * 获取完整的文件访问URL
     */
    public String getFullFileUrl(String filePath) {
        if (filePath == null || filePath.isEmpty()) {
            return "";
        }
        
        if (filePath.startsWith("http")) {
            return filePath;
        }
        
        return baseUrl + filePath;
    }
}
